<template>
	<view>
		<view class="index-list" style="margin-top: 40rpx;">
			<view class="index-list3">
				<!-- 图片 -->
				<image :src="item.typesrc" mode="widthFix"></image>
			</view>
			<view style="display: flex; justify-content: space-between;">
				<view @click="index1" class="icon iconfont icon-shoucang1">收藏</view>
				<view @click="index2" class="icon iconfont icon-shoucang1">下载</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			item: Object,
		},
		data() {
			return {
				obj: Object
			};
		},
		methods: {
			index1() {
				console.log("收藏")
			},
			index2() {
				console.log("ok")
				const downloadTask = uni.downloadFile({
				    url: 'https://tva2.sinaimg.cn/large/0072Vf1pgy1foxloatthsj31kw0w07sn.jpg', //仅为示例，并非真实的资源
				    success: (res) => {
				        if (res.statusCode === 200) {
				            console.log('下载成功');
				        }
				    }
				});
				
				downloadTask.onProgressUpdate((res) => {
				    console.log('下载进度' + res.progress);
				    console.log('已经下载的数据长度' + res.totalBytesWritten);
				    console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
				
				    // 测试条件，取消下载任务。
				    if (res.progress > 50) {
				        downloadTask.abort();
				    }
				});
			}
		}
	}
</script>

<style>
	.index-list {
		padding: 20upx;
		border-bottom: 1upx solid #8e9293;
	}

	.index-list3>image {
		width: 100%;
		border-radius: 6px;
	}

	.index-list3 {
		position: relative;
	}
</style>
